package com.hmall.search.controller;


import com.hmall.search.pojo.Item;
import com.hmall.search.pojo.PageDTO;
import com.hmall.search.pojo.RequestParams;
import com.hmall.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("search")
public class SearchController {

    @Autowired
    SearchService searchService;

    @GetMapping("suggestion")
    public List<String> getSuggestions(@RequestParam("key") String key) {
         return searchService.getSuggestions(key);
    }

    //搜索功能
    @PostMapping("list")
    public PageDTO getList(@RequestBody RequestParams params) {
        return searchService.PostSearch(params);
    }


    @PostMapping("filters")
    public Map<String,List<String>> juheQuery(@RequestBody RequestParams params){
        return searchService.juheQuery(params);
    }

}
